package com.trainingcloud.utils;

import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.nio.file.Path;

/**
 * @Classname TokenUtil
 * @Date 2022/10/11 10:55
 * @Author 纸鹤超努力
 */
@Component
public class MyVideoUtil extends ResourceHttpRequestHandler {

    public final static String FILE_PATH = "NON-STATIC-FILE";

    public Resource getResource(HttpServletRequest request) throws IOException {
        final Path filePath = (Path)request.getAttribute(FILE_PATH);
        return new FileSystemResource(filePath);
    }
}
